package api

import (
	"net/http"
	"gitee.com/DengAnbang/streamWeb/api/defs"
	"html/template"
	"gitee.com/DengAnbang/goutils/loge"
)

func WebLogin(w http.ResponseWriter, r *http.Request) error {
	t, err := template.ParseFiles(defs.VIEW_DIR + "index.html")
	if err != nil {
		return err
	}
	cookie := http.Cookie{Name: "cookieName", Value: "", Path: "/", MaxAge: 86400}
	http.SetCookie(w, &cookie)
	t.Execute(w, nil)
	return nil
}
func WebHome(w http.ResponseWriter, r *http.Request) error {
	cookie, err := r.Cookie("cookieName")
	if err == nil {
		cookievalue := cookie.Value
		loge.E("cookie的值是：" + cookievalue)
	} else {
		loge.E("<b>读取出现错误：" + err.Error() + "</b>\n")
	}
	r.ParseForm()
	loge.E(r.Form.Get("pwd"))
	t, err := template.ParseFiles(defs.VIEW_DIR + "home.html")
	if err != nil {
		return err
	}
	t.Execute(w, nil)
	return nil
}
